In some cases, optimization among source files (such as inline deployment, constant propagation, or the like) may be useful for a source file including a source program described in a programming language such as C, C++, or Fortran. Optimization among source files is performed after the entire source files are confirmed based on object files that are made ready during linking. Optimization among source files during linking is called link time optimization (LTO).
When link time optimization is performed, an object file that includes an object code generated through compilation (hereinafter referred to as first-path compilation) and source program information is generated. Then, optimization is performed using the source program information in the object file during linking. Then, recompilation (hereinafter referred to as second-path compilation) is performed on a result of the optimization. An object code resulting from the recompilation is linked, so that build is completed.
When link time optimization is not performed, an object file including a result of first-path compilation is linked. However, since an object file including a result of second-path compilation is linked when link time optimization is performed, the object file including the result of the first-path compilation is not linked.
For this reason, first-path compilation is useless processing when link time optimization is performed. Nevertheless, such a method is adopted to be able to deal with both of the case in which link time optimization is performed and the case in which link time optimization is not performed. However, this contributes to extended time till an executable file is generated. In the conventional technique, no consideration is given to such a problem in link time optimization.
Related techniques are disclosed, for example, in Japanese Laid-open Patent Publication Nos. 2003-208317 and 9-274570.